package dao

import "time"

// 这是 ReadingTime 的全局公开dao对象
var ReadingTimeDao = readingTimeDao{}

// 注意:这是 ReadingTime 的私有dao对象
type readingTimeDao struct {
	Obj    ReadingTime
	Insert func(arg ReadingTime) int64       //插入一条记录
	Update func(arg ReadingTime) int64       //更新一条记录
	Delete func(arg ReadingTime) int64       //删除一条记录
	Select func(arg ReadingTime) ReadingTime //获取一条记录
	GetReadingTime func(uid int,start,end string)int `arg:"uid,start_time,end_time"`
}

func (it *readingTimeDao)GetReadTime(uid int,prd period)int{
	now := time.Now()
	if prd == PeriodAll {
		m := Member{MemberId: uid}
		return MemberDao.Select(m).TotalReadingTime
	}
	start,end := getTimeRange(now,prd)
	return it.GetReadingTime(uid, start, end)
}

func (it *readingTimeDao)Sort(prd period,limit int,withCache ...bool)int{

}
